<%@ page language="java" pageEncoding="utf-8" %>
<%@ page import="java.util.List" %>
<%@ page import="com.wc.pojo.User" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<html contextType="multipart/form-data; charset=utf-8" >
<head>
    <meta charset="utf-8">
    <title>用户信息列表</title>

    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/bootstrap/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/datetimepicker/css/bootstrap-datetimepicker.min.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/css/bootstrap-select.min.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/tree/css/treestyle/treestyle.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/css/reveal.css"/>

    <script src="${pageContext.request.contextPath}/statics/js/jquery.min.js" type="text/javascript" charset=utf-8></script>
    <script src="${pageContext.request.contextPath}/statics/bootstrap/js/bootstrap.min.js" type="text/javascript" charset=utf-8></script>
    <script src="${pageContext.request.contextPath}/statics/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/datetimepicker/js/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="${pageContext.request.contextPath}/statics/selectpicker/js/bootstrap-select.min.js" type="text/javascript" charset=utf-8></script>
    <script src="${pageContext.request.contextPath}/statics/selectpicker/js/defaults-zh_CN.min.js" type="text/javascript" charset=utf-8></script>

    <script src="${pageContext.request.contextPath}/statics/tree/js/jquery.ztree.core.min.js" type="text/javascript" charset=utf-8></script>
    <script src="${pageContext.request.contextPath}/statics/tree/js/jquery.ztree.excheck.min.js" type="text/javascript" charset=utf-8></script>

    <script src="${pageContext.request.contextPath}/statics/js/time.js" type="text/javascript" charset=utf-8></script>
    <script src="${pageContext.request.contextPath}/statics/js/tree/treeList.js" type="text/javascript" charset=utf-8></script>
    <script src="${pageContext.request.contextPath}/statics/js/user/userList.js" type="text/javascript" charset=utf-8></script>
    <script src="${pageContext.request.contextPath}/statics/js/tree/changeTree.js" type="text/javascript" charset=utf-8></script>
    <script src="${pageContext.request.contextPath}/statics/js/user/changeUser.js" type="text/javascript" charset=utf-8></script>

</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-2 column ui-sortable">
            <%--<span>欢迎用户${user.username}</span>
            <a href="javascript:goutUser()" type="button" class="btn btn-danger btn-xs">退出</a>--%>
            <span id="time"></span>
        </div>
        <div class="col-md-6 column ui-sortable">
            <form class="navbar-form" role="search"
                  action="javascript:search()">
                <div class="form-group">
                    <input type="text" class="form-control" name="Dm" placeholder="代码">
                </div>
                <div class="form-group">
                    <input type="text" class="form-control" name="userName" placeholder="用户名">
                </div>
                <button type="submit" class="btn btn-default btn-success">查询</button>
            </form>
        </div>
        <div class="col-md-4 column ui-sortable">
            <a class="btn btn-info" href="#modal-container" data-toggle="modal" onclick="getAdd()">添加用户</a>
            <a class="btn btn-info" href="#modal-container-xm" data-toggle="modal" onclick="getAddXm()">添加项目</a>
            <a class="btn btn-info" href="#modal-container-bm" data-toggle="modal" onclick="getAddBm()">添加部门</a>
            <a class="btn btn-info" href="#modal-container-excel" data-toggle="modal">Excel操作</a>
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-2 column ui-sortable">
            <%-- 菜单列 --%>
            <ul id="tree" class="ztree"></ul>
        </div>
        <div class="col-md-10 column ui-sortable">
            <%-- 数据展示 --%>
            <table class="table table-bordered">
                <thead id="thead_list">
                </thead>
                <tbody id="tbody_list">
                </tbody>
            </table>
                <div class="col-md-6 column ui-sortable">
                    <span id="page_text"></span>
                </div>
                <div class="col-md-6 column ui-sortable">
                        <ul class="pagination pagination-sm" id="page_li">
                            <li><a id="start">首页</a></li>
                            <li><a id="pert">&laquo;</a></li>
                            <li id="page_list"></li>
                            <li><a id="next">&raquo;</a></li>
                            <li><a id="end">尾页</a></li>
                        </ul>
                </div>
        </div>
    </div>
</div>

<%-- 用户模态框 --%>
<div class="modal fade" id="modal-container" tabindex="-1"
     role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
     style="display: none;">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title" id="myModalLabel">标题</h4>
            </div>
                <div class="modal-body">
                <!-- 内容区 -->
                <div class="form-group ID_text">
                    <label for="userid" >ID</label>
                        <input type="hidden" class="form-control" name="userid" value=""
                               id="userid" placeholder="ID值">
                </div>
                <div class="form-group">
                    <label for="name" >用户名</label>
                        <input type="text" class="form-control" id="name"
                               placeholder="用户名" value="" name="name">

                </div>
                <div class="form-group">
                    <label for="idcard" >身份证号码</label>
                        <input type="text" id="idcard" class="form-control"
                               placeholder="身份证号码" name="idcard">
                        <span id="msg"></span>
                </div>
                <div class="form-group">
                    <label for="mobiile">手机号码</label>
                        <input type="text" id="mobiile" class="form-control"
                               placeholder="手机号码" value="" name="mobiile">
                </div>
                <div class="form-group">
                    <label for="address" >地址</label>
                        <input type="text" id="address" class="form-control"
                               placeholder="地址" value="" name="address">
                </div>
                    <div class="form-group age_text">
                        <label for="age" >年龄</label>
                        <input type="number" class="form-control" id="age"
                               placeholder="年龄" name="age">
                    </div>
                <div class="form-group birtday_text">
                    <label for="dtp_input1" class="control-label">出生日期</label>
                    <div class="input-group date form_datetime" data-date="" data-date-format="dd MM yyyy - HH:ii p" data-link-field="dtp_input1">
                        <input name="birtday" class="form-control" size="16" type="text" value="" readonly>
                        <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                        <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                        <input type="hidden" id="dtp_input1" value="" />
                    </div>
                </div>
                <div class="form-group">
                        <input type="submit" class="form-control btn btn-success btn-sm" value="" id="submit_user"/>
                </div>
                    <span id="error"></span>
            </div>
        </div>
    </div>
</div>
<%-- 修改项目名称模态框 --%>
<div class="modal fade" id="modal-container-two" tabindex="-1"
     role="dialog" aria-labelledby="myModalLabel-s" aria-hidden="true"
     style="display: none;">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title">修改项目名称</h4>
            </div>
            <div class="modal-body">
                <!-- 内容区 -->
                <div class="form-group ID_text_two">
                    <label for="tId" >ID</label>
                    <input type="hidden" class="form-control" name="tId" value=""
                           id="tId" placeholder="ID">
                </div>
                <div class="form-group">
                    <label for="name" >项目名称</label>
                    <input type="text" class="form-control"
                           placeholder="用户名" value="" name="xmName">

                </div>
                <div class="form-group">
                    <input type="submit" class="form-control btn btn-success btn-sm" value="" id="submit_two"/>
                </div>
                <span id="error_two"></span>
            </div>
        </div>
    </div>
</div>
<%-- 修改部门名称模态框 --%>
<div class="modal fade" id="modal-container-one" tabindex="-1"
     role="dialog" aria-labelledby="myModalLabel-s" aria-hidden="true"
     style="display: none;">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title">修改部门名称</h4>
            </div>
            <div class="modal-body">
                <!-- 内容区 -->
                <div class="form-group ID_text_one">
                    <label for="tId" >ID</label>
                    <input type="hidden" class="form-control" name="tId" value=""
                           placeholder="ID">
                </div>
                <div class="form-group">
                    <label for="name" >部门名称</label>
                    <input type="text" class="form-control"
                           placeholder="用户名" value="" name="bmName">

                </div>
                <div class="form-group">
                    <input type="submit" class="form-control btn btn-success btn-sm" value="" id="submit_one"/>
                </div>
                <span id="error_one"></span>
            </div>
        </div>
    </div>
</div>
<%-- excel模态框 --%>
<div class="modal fade" id="modal-container-excel" tabindex="-1"
     role="dialog" aria-labelledby="myModalLabel-s" aria-hidden="true"
     style="display: none;">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title">Excel操作</h4>
            </div>
            <div class="modal-body">
                <!-- 内容区 -->
                    <div class="form-group">
                        <label for="upfile">上传表格(仅支持Excel)</label>
                        <input id="upfile" type="file" class="file" accept=".xls,.xlsx" name="upfile"/>
                    </div>
                    <div class="form-group">
                        <input type="button" class="form-control btn btn-success btn-sm" value="导入" id="importExcel">
                    </div>
                    <div class="form-group">
                        <input class="form-control btn btn-success btn-sm" type="button" value="导出" id="downloadExcel">
                    </div>
            </div>
        </div>
    </div>
</div>
<%-- 部门模态框 --%>
<div class="modal fade" id="modal-container-bm" tabindex="-1"
     role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
     style="display: none;">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title" id="title_bm">标题</h4>
            </div>
            <div class="modal-body">
                <!-- 内容区 -->
                <div class="form-group ID_text_m">
                    <label for="tId" >部门ID</label>
                    <input type="hidden" class="form-control" name="tId" value=""
                           id="tId" placeholder="部门ID">
                </div>
                <div class="form-group xmNames_text">
                    <label for="bmNames" >部门名称</label>
                    <input type="text" class="form-control" id="bmNames"
                           placeholder="部门名称" value="" name="bmNames">
                    <span id="bmNames_text"></span>
                </div>
                <div class="form-group">
                    <label for="bmDm" >部门代码</label>
                    <input type="text" class="form-control" id="bmDm"
                           placeholder="部门代码" value="" name="bmDm">
                    <span id="bmDm_text"></span>
                </div>
                    <div class="form-group">
                        <input type="submit" class="form-control btn btn-success btn-sm" value="" id="submit_bm"/>
                    </div>
                    <span id="error_bm"></span>

            </div>
        </div>
    </div>
</div>
<%-- 项目模态框 --%>
<div class="modal fade" id="modal-container-xm" tabindex="-1"
     role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
     style="display: none;">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title" id="title_xm">标题</h4>
            </div>
            <div class="modal-body">
                <!-- 内容区 -->
                <div class="form-group ID_text_xm">
                    <label for="xmId" >项目ID</label>
                    <input type="hidden" class="form-control" name="xmId" value=""
                           id="xmId" placeholder="项目ID">
                </div>
                <div class="form-group xmNames_text">
                    <label for="xmNames" >项目名称</label>
                    <input type="text" class="form-control" id="xmNames"
                           placeholder="项目名称" value="" name="xmNames">
                    <span id="xmNames_text"></span>
                </div>
                <div class="form-group">
                    <label for="xmDm" >项目代码</label>
                    <input type="text" class="form-control" id="xmDm"
                           placeholder="项目代码" value="" name="xmDm">
                    <span id="xmDm_text"></span>
                </div>
                <div class="form-group select_bm">
                    <label>选择添加到指定部门</label>
                    <select class="selectpicker" data-width="318px" id="node_list"></select>
                </div>
                <span id="error_xm_text"></span>
                <div id="information" style="display: none">
                    <div class="form-group">
                        <label for="xmOwnerid" >项目负责人ID</label>
                        <input type="text" id="xmOwnerid" class="form-control"
                               placeholder="项目负责人ID" name="xmOwnerid">
                        <span id="xmOwnerid_text"></span>
                    </div>
                    <div class="form-group">
                        <label for="xmJea">项目金额A</label>
                        <input type="number" id="xmJea" class="form-control"
                               placeholder="项目金额A" value="" name="xmJea">
                    </div>
                    <div class="form-group">
                        <label for="xmJezb" >项目金额B</label>
                        <input type="number" id="xmJezb" class="form-control"
                               placeholder="项目金额B" value="" name="xmJezb">
                    </div>
                    <div class="form-group">
                        <label for="xmJejc" >项目金额C</label>
                        <input type="number" id="xmJejc" class="form-control"
                               placeholder="项目金额C" value="" name="xmJejc">
                    </div>
                    <div class="form-group xmOldtime_text">
                        <label for="dtp_input2" class="control-label">修改时间</label>
                        <div class="input-group date form_datetime" data-date="" data-date-format="dd MM yyyy - HH:ii p" data-link-field="dtp_input2">
                            <input name="xmOldtime" class="form-control" size="16" type="text" value="" readonly>
                            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                            <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                            <input type="hidden" id="dtp_input2" value="" />
                        </div>
                    </div>
                    <div class="form-group xmTime_text">
                        <label for="dtp_input3" class="control-label">创建时间</label>
                        <div class="input-group date form_datetime" data-date="" data-date-format="dd MM yyyy - HH:ii p" data-link-field="dtp_input3">
                            <input name="xmTime" class="form-control" size="16" type="text" value="" readonly>
                            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                            <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                            <input type="hidden" id="dtp_input3" value="" />
                        </div>
                    </div>
                    <div class="form-group">
                        <input type="submit" class="form-control btn btn-success btn-sm" value="" id="submit_xm"/>
                    </div>
                    <span id="error_xm"></span>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
</html>
<script>
    $(function () {
        $('#node_list').click(function (){
            alert("dasdasdasd")
        })
        var t = setInterval(dataTime, 1000);
        $(".form_datetime").datetimepicker({
            format: "yyyy-mm-dd hh:ii",
            language : 'zh-CN',
            weekStart: 1,
            todayBtn:  1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            showMeridian: 1,
            initialDate : new Date(),
            pickerPosition:'top-right'
        });

        // $('.selectpicker').selectpicker('val','mustard');
        //
        // $('.selectpicker').selectpicker('val',['mustard','relish']);
        //
        // $('.selectpicker').selectpicker('refresh');
        //
       // $('#node_list').on('changed.bs.select',function(e){
       //     var $node_list = $('#node_list')
       //     $node_list.empty()
       //      $.ajax({
       //          type: "get",
       //          url: "getTreeNodelist",
       //          success:function (data){
       //              if (data.length != 0){
       //                  for (var x in data) {  //<optgroup label="系统设置">
       //                      if (data[x].id)
       //                      var option = '<option value="' + data[x].id + '" data-tokens="'+ data[x].name+'">' + data[x].name+ '</option>'
       //                      $node_list.append(option)
       //                  }
       //              }
       //              $('#node_list').selectpicker('refresh')
       //          }
       //      })
       // })



            $("#importExcel").on("click",function (){
                    var formData = new FormData()
                    //检验导入的文件是否为Excel文件
                    var uploadFile = $('#upfile').val()
                    formData.append("upfile",$("#upfile")[0].files[0])
                    formData.append("name",uploadFile)
                    if(uploadFile == null || uploadFile == ''){
                        alert("请选择要上传的Excel文件")
                        return false;
                    }else{
                        var fileExtend = uploadFile.substring(uploadFile.lastIndexOf('.')).toLowerCase();
                        if(fileExtend == '.xls' || fileExtend == '.xlsx'){
                            $.ajax({
                                url:"ajaxUpload",
                                type:"POST",
                                data:formData,
                                processData:false,
                                contentType:false,
                                success:function (data) {
                                    if (data == '1'){
                                        alert("导入成功")
                                    }else{
                                        alert("导入失败,日志有错误信息")
                                    }
                                }

                            })
                            return true
                        }else{
                            alert("文件格式需为.xls格式或者.xlsx格式");
                            return false
                        }
                    }
            })

            $("#downloadExcel").on("click",function (){
                //弹出对话框
                var result = confirm("是否导出Excel？")
                if (result) {
                    $.post('downloadExcel')//直接发出请求不需要参数啥的
                }
            })
    })







</script>